// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.ast.statement.SQLAnalyzeTableStatement;
// import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.List;

#include "MySqlAnalyzeStatement.h"
#include "../../../../../DbType.h"
#include "../../../../ast/statement/SQLExprTableSource.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../visitor/SQLASTVisitor.h"
#include "../../../../../utils/instanceof.h"
#include "../../../../../utils/listTran.h"

MySqlAnalyzeStatement::MySqlAnalyzeStatement()
{
  SQLAnalyzeTableStatement::dbType = DbType_ptr(new DbType(&DbType::mysql));
}

// @Override
void MySqlAnalyzeStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (instanceof <SQLASTVisitor, MySqlASTVisitor>(visitor))
  {
    accept0(std::dynamic_pointer_cast<MySqlASTVisitor>(visitor));
  }
  else
  {
    SQLAnalyzeTableStatement::accept0(visitor);
  }
}

void MySqlAnalyzeStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlAnalyzeStatement)))
  {
    SQLObject_list_ptr tmp = ListTran::tran_class<SQLExprTableSource, SQLObject>(tableSources);
    acceptChild(visitor, tmp);
  }
  visitor->endVisit(SharedObject(MySqlAnalyzeStatement));
}

BOOL_ptr MySqlAnalyzeStatement::isNoWriteToBinlog()
{
  return noWriteToBinlog;
}

void MySqlAnalyzeStatement::setNoWriteToBinlog(BOOL_ptr noWriteToBinlog)
{
  this->noWriteToBinlog = noWriteToBinlog;
}

BOOL_ptr MySqlAnalyzeStatement::isLocal()
{
  return local;
}

void MySqlAnalyzeStatement::setLocal(BOOL_ptr local)
{
  this->local = local;
}

SQLExprTableSource_list_ptr MySqlAnalyzeStatement::getTableSources()
{
  return tableSources;
}

void MySqlAnalyzeStatement::addTableSource(SQLExprTableSource_ptr tableSource)
{
  if (tableSource != nullptr)
  {
    tableSource->setParent(SharedObject(MySqlAnalyzeStatement));
  }
  this->tableSources->push_back(tableSource);
}
